<template>
<div class="merchandise-categories-add views-container">
    <div class="wlm-form">
      <div class="wlm-form-header">基础设置</div>
        <div class="wlm-form-content" v-if="$values">
            <el-form :ref="formFormatData.key" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="120px" class="retail-form" label-position="right">
                <el-form-item label="发送时间点">
                    <span v-if="$route.query.key=='register'">用户注册时</span>
                    <span v-if="$route.query.key=='findBack'">找回密码时</span>
                    <span v-if="$route.query.key=='payCheck'">核销订单支付成功时</span>
                </el-form-item>
            </el-form>
        </div>
        <div class="wlm-form-header">短信设置</div>
        <div class="wlm-form-content" v-if="$values">
            <el-form :ref="formFormatData.key" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="120px" class="retail-form" label-position="right">
                <el-form-item label="模板ID">
                    <el-input placeholder="模板ID" v-model="$values.sms.templateid"></el-input>
                    <div class="form-help" v-if="$route.query.key=='register'">模板内容：您的验证码为：${code}，您正在注册用户账号，如非本人操作请忽略。</div>
                    <div class="form-help" v-if="$route.query.key=='findBack'">模板内容：您的验证码为：${code}，您正在进行密码重置操作，如非本人操作，请忽略本短信！</div>
                </el-form-item>
                <el-form-item label="是否开启">
                    <el-radio-group v-model="$values.sms.status">
                        <el-radio label="1">开启</el-radio>
                        <el-radio label="0">关闭</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-form>
        </div>
    </div>
    <div v-cloak class="wlm-fixed-btn flex-row flex-align-c flex-justify-c">
        <el-button size="small" @click="formFormatSubmit({ router: { type: 'replace', path: '/application/notification', code: 1 }})" type="primary">保存</el-button>
    </div>
</div>
</template>

<script>
import {
  smsTplGet,
  smsTplSave
} from '@/api/application'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Form')],
  name: 'NotificationAdd',
  components: {

  },
  directives: {

  },
  computed: {
    $values() {
      return this.formFormatData.formData.values[`${this.$route.query.key}`]
    }
  },
  data() {
    return {
      formFormatData: {
        key: 'userForm',
        api: {
          editForm: {
            api: smsTplGet,
            params: {
              id: ''
            },
            redirect: 'type'
          },
          submitForm: smsTplSave
        },
        formData: {
          key: this.$route.query.key,
          values: {
            [`${this.$route.query.key}`]: {
              sms: {
                status: '1',
                templateid: ''
              }
            }
          }
        },
        rules: {
          // name: [{
          //   required: true,
          //   message: '请输入真实姓名',
          //   trigger: 'blur'
          // }],
          // image_id: [{
          //   required: true,
          //   message: '请输入真实姓名',
          //   trigger: 'blur'
          // }],
          // sort: [{
          //   required: true,
          //   message: '请输入真实姓名',
          //   trigger: 'blur'
          // }],
        }
      }
    }
  },
  methods: {

  }
}
</script>

<style lang="scss" scoped>
.merchandise-categories-add {}
</style>
